package com.mrd.util;

import com.mrd.constant.MsgConstants;

public class MsgBuildUtil {
    /**
     * 在现有的msgConstant后面追加其他提示信息
     */
    public static String appendMsg(String msgConstant, String appendedMsg) {
        String result = msgConstant.substring(0, msgConstant.length() - 2) + appendedMsg
                + msgConstant.substring(msgConstant.length() - 2);
        return result;
    }

    /**
     * 在现有的msgConstant后面添加data，最初设计用于ajax保存时返回ID
     */
    public static String appendData(String msgConstant, String data) {
        String result = msgConstant.substring(0, msgConstant.length() - 1) + ",\"data\":\"" + data
                + "\"" + msgConstant.substring(msgConstant.length() - 1);
        return result;
    }

    public static void main(String[] args) {
        System.out.println(appendMsg(MsgConstants.SAVE_FAIL, "aaaaa"));
    }
}
